feedbackController = function() {}

feedbackController.prototype.saveFeedbackForm = function() {
    var form = '';
        form = $('#feedback_form');
        commonController.showLoader('#feedback_form');
    
        $.ajax({
            url: $(form).attr('action'),
            type: 'post',
            dataType: 'json',
            data: $(form).serialize(),
            timeout: 12000,
            async: true,
            error: function() {
                commonController.showConnectionError()
                commonController.hideLoader('#feedback_form');
            },
            success: function(data) {
                commonController.hideLoader('#feedback_form');
                if((typeof(data.errors) != 'undefined') && (data.errors != '')) {
                    if((typeof(data.csrf_token) != 'undefined') && (data.csrf_token != '')) {
                        $('#csrf_token').val(data.csrf_token);
                    }

                    commonController.showErrorMessage(data.errors);
                } else {
                    if(typeof(data.status) != 'undefined' && data.status == true) {
                        commonController.showSuccessMessage(data.success_message);
                        
                        $('#feedback_user_name').val('');
                        $('#feedback_email').val('');
                        $('#feedback_text').val('');
                    }
                }
            }
        });
    
    return false;
}

feedbackController = new feedbackController();